/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bookingticketsws;

import bookingtickets.BookingTicketsSessionRemote;
import bookingtickets.Ticket;
import bookingtickets.Trip;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.jws.WebService;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 *
 * @author alexxxey
 */
@WebService(serviceName = "BookingTicketsWs")
@Stateless()
public class BookingTicketsWs
{
    @EJB
    private BookingTicketsSessionRemote ejbRef;
    
    /**
     * Получение списка всех доступных маршрутов
     */
    @WebMethod(operationName = "getAllTrips")
    public List<Trip> getAllTrips()
    {
        return ejbRef.getAllTrips();        
    }
    
    /**
     * Поиск маршрута по номеру     
     */
    @WebMethod(operationName = "findTripById")
    public Trip findTripById(
            @WebParam(name = "tripId") int tripId)
    {
        return ejbRef.findTripById(tripId);
    }

    /**
     * Поиск маршрутов по дате
     */
    @WebMethod(operationName = "findTripsByDate")
    public List<Trip> findTripsByDate(
            @WebParam(name = "date") Date date)
    {
        return ejbRef.findTripsForDate(date);        
    }
    
    /**
     * Поиск маршрутов по месту назнаения
     */
    @WebMethod(operationName = "findTripsByDestination")
    public List<Trip> findTripsByDestination(
            @WebParam(name = "destination") String dest)
    {
        return ejbRef.findTripsForDestinations(dest);
        
    }
    
    /**
     * Резервирование билета
     */                
    @WebMethod(operationName = "reseserveTickets")    
    public void reserveTickets(
            @WebParam(name = "tripId") int tripId, 
            @WebParam(name = "place") int place, 
            @WebParam(name = "firstName") String firstName, 
            @WebParam(name = "lastName") String lastName, 
            @WebParam(name = "pasport") int pasport)
    {
        ejbRef.reserveTickets(tripId, place, firstName, lastName, pasport);
    }
    
    /**
     * Список зарезервированных билетов по номеру паспорта 
     */
    @WebMethod(operationName = "getReservedTickets")
    public List<Ticket> getReservedTickets(
            @WebParam(name = "pasport") int pasport)
    {
        return ejbRef.reservedTickets(pasport);        
    }
    
    /**
     * Отмена резервирования билета
     */ 
    @WebMethod(operationName = "cancelReserve")
    public void cancelReserve(
            @WebParam(name = "place") int place, 
            @WebParam(name = "tripId") int tripId)
    {
        ejbRef.cancelReserve(place, tripId);
    }
    
    /** 
     * Получение списка свбодных мест на маршрут
     */
    @WebMethod(operationName = "getFreePlacesList")
    public List<Integer> getFreePlacesList(
            @WebParam(name = "tripId") int tripId)
    {
        return ejbRef.getFreePlacesList(tripId);        
    }
    
    /** 
     * Получение списка пункутов назначений
     */
    @WebMethod(operationName = "getDestinationsList")
    public List<String> getDestinationsList(
            @WebParam(name = "tripId") int tripId)
    {
        return ejbRef.getDestinationsList(tripId);        
    }

}
